<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
	<TITLE></TITLE>
	<META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2  (Unix)">
	<META NAME="CREATED" CONTENT="0;0">
	<META NAME="CHANGED" CONTENT="20101228;16594900">
	<STYLE TYPE="text/css">
	<!--
		@page { margin: 0.79in }
		P { margin-bottom: 0.08in }
		PRE { font-family: "Times New Roman" }
	-->
	</STYLE>
</HEAD>
<BODY LANG="el-GR" DIR="LTR">
<PRE LANG="en-US"><FONT SIZE=5><B>rk3n</B></FONT>

<FONT SIZE=4><SPAN LANG="en-US">Solves an initial value problem, for a system of second order ordinary differ<SPAN STYLE="font-style: normal">ential equation</SPAN><SPAN STYLE="font-style: normal">s</SPAN><SPAN STYLE="font-style: normal"> without first derivative</SPAN></SPAN></FONT>


<FONT SIZE=4><SPAN LANG="en-US"><B>Example: Can be run with F5 within the ScalaLab Editor (Ctrl-E to open the editor)</B></SPAN></FONT>

<FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">import java.text.DecimalFormat;</SPAN></FONT>
<FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">import numal.*;</SPAN></FONT>

<FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">public class Test_rk3n extends Object implements AP_rk3n_method {</SPAN></FONT>

<FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">	public static void main(String args[]) {</SPAN></FONT>

    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">boolean fi;</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">int k,i,n,j;</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">double b,x2,term;</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">double y[] = new double[3];</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">double ya[] = new double[3];</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">double z[] = new double[3];</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">double e[] = new double[9];</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">double d[] = new double[8];  </SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">double x[] = new double[1];</SPAN></FONT>
    
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">Test_rk3n testrk3n = new Test_rk3n();</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">DecimalFormat twoDigit = new DecimalFormat(&quot;0.00E0&quot;);</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">System.out.println(&quot;Results from RK3N :\n&quot;);</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">for (k=1; k&lt;=8; k++) e[k]=1.0e-5;</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">fi=true;</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">y[1]=y[2]=1.0;</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">z[1]=z[2]=0.0;</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">b=0.0;</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">do {</SPAN></FONT>
      <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">b += 1.0;</SPAN></FONT>
      <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">Analytic_problems.rk3n(x,0.0,b,y,y,z,z,testrk3n,e,d,fi,2);</SPAN></FONT>
      <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">ya[1]=ya[2]=0.0;</SPAN></FONT>
      <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">term=1.0;</SPAN></FONT>
      <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">x2=x[0]*x[0]*0.5;</SPAN></FONT>
      <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">n=1;</SPAN></FONT>
      <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">do {</SPAN></FONT>
        <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">for (i=1; i&lt;=2; i++) {</SPAN></FONT>
          <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">j=(i+n-2)/2;</SPAN></FONT>
          <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">ya[i] += term*((j%2 == 0) ? 1 : -1);</SPAN></FONT>
        <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">}</SPAN></FONT>
        <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">term=term*x2/n/(n*2-1);</SPAN></FONT>
        <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">n++;</SPAN></FONT>
      <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">} while (Math.abs(term) &gt; 1.0e-14);</SPAN></FONT>
      <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">System.out.println(&quot; ABS(YEXACT[1]-Y[1])+&quot; + </SPAN></FONT>
        <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">&quot;ABS(YEXACT[2]-Y[2]) = &quot; +</SPAN></FONT>
        <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">twoDigit.format(Math.abs(y[1]-ya[1])+</SPAN></FONT>
                        <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">Math.abs(ya[2]-y[2])));</SPAN></FONT>
      <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">fi=false;</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">} while (b &lt; 5.0);</SPAN></FONT>
<FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">	}</SPAN></FONT>


  <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">public double fxyj(int n, int j, double x[], double y[])</SPAN></FONT>
  <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">{</SPAN></FONT>
    <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">return ((j == 1) ? y[2] : -y[1]);</SPAN></FONT>
  <FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">}</SPAN></FONT>
<FONT SIZE=2 STYLE="font-size: 11pt"><SPAN LANG="en-US">}</SPAN></FONT></PRE>
</BODY>
</HTML>